#region

using System;
using ThuySan.Bussiness;

#endregion

namespace ThuySan.Models
{
    [Serializable]
    public partial class ProductPropertyModel
    {
        #region Constructor

        public ProductPropertyModel()
        {
        }

        public ProductPropertyModel(ProductProperty value)
        {
            ProductPropertyId = value.ProductPropertyId;
            PropertyId = value.PropertyId;
            ProductId = value.ProductId;
            Bit = value.Bit ?? false;
            Numer = value.Numer;
            Value = value.Value;
        }

        #endregion

        #region Fields

        private bool _Bit;

        private Int32? _Numer;

        private Int32? _ProductId;

        private Int32 _ProductPropertyId;

        private Int32? _PropertyId;

        private String _Value;

        #endregion

        #region Properties

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public Int32 ProductPropertyId
        {
            get { return _ProductPropertyId; }
            set { _ProductPropertyId = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public Int32? PropertyId
        {
            get { return _PropertyId; }
            set { _PropertyId = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public Int32? ProductId
        {
            get { return _ProductId; }
            set { _ProductId = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public bool Bit
        {
            get { return _Bit; }
            set { _Bit = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public Int32? Numer
        {
            get { return _Numer; }
            set { _Numer = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public String Value
        {
            get { return _Value; }
            set { _Value = value; }
        }

        #endregion

        #region Operators

        public void Update(ProductProperty value)
        {
            //value.ProductPropertyId = ProductPropertyId;
            value.PropertyId = PropertyId;
            value.ProductId = ProductId;
            value.Bit = Bit;
            value.Numer = Numer;
            value.Value = Value;
        }

        public static implicit operator ProductPropertyModel(ProductProperty obj)
        {
            return new ProductPropertyModel(obj);
        }

        public static implicit operator ProductProperty(ProductPropertyModel obj)
        {
            ProductProperty value = new ProductProperty();
            obj.Update(value);
            return value;
        }

        #endregion
    }
}
